<%
' +----------------------------------------------------------------------
' | POPASP [ ASP MVC ]
' +----------------------------------------------------------------------
' | Copyright (c) 2016 http://popasp.com All rights reserved.
' +----------------------------------------------------------------------
' | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
' +----------------------------------------------------------------------
' | Author: popasp <1737025626@qq.com>
' +----------------------------------------------------------------------
' 项目布置类
Class POPASP_STRUCTRUE
	private fso
	private sub Class_Initialize
		set fso = POP_MVC.fso
	end sub
	
	sub handler
		set fso = POP_MVC.fso
		if not folder_exists(APP_PATH) Then
			call mkDir( APP_PATH )		
			call mkDir( APP_PATH & "/Common" )		
			call mkDir( APP_PATH & "/Conf" )		
			call mkDir( APP_PATH & "/Controller" )		
			call mkDir( APP_PATH & "/Model" )		
			call mkDir( APP_PATH & "/Runtime" )		
			call mkDir( APP_PATH & "/Tpl" )		
			call mkDir( APP_PATH & "/Runtime/Cache" )	
			call mkDir( APP_PATH & "/Runtime/Class" )	
			call mkDir( APP_PATH & "/Runtime/Compile" )	
			call mkDir( APP_PATH & "/Runtime/Data" )	
			call mkDir( APP_PATH & "/Runtime/Temp" )
			call mkDir( APP_PATH & "/Runtime/Log" )
			
			call copyFile( POP_MVC.mvc_dir & "Tpl/default_index.html" , APP_PATH & "/Controller/IndexAction.class.asp" )
			call copyFile( POP_MVC.mvc_dir & "Tpl/default_config.html" , APP_PATH & "/Conf/config.asp" )
			call copyFile( POP_MVC.mvc_dir & "Tpl/default_common.html" , APP_PATH & "/Common/common.asp" )
		end if
	End sub	
	
	sub copyFile( src,dst )
		if file_exists(src) and not file_exists(dst) Then
			fso.copyfile POP_MVC.realPath(src),POP_MVC.realPath(dst)
		end if
	end Sub
	
	sub mkDir( folderPath )
		if not folder_exists( folderPath ) then
			call create_folder(  folderPath )
		end if
	end Sub
	
	Private Function file_exists( filePath )
		file_exists = fso.FileExists( POP_MVC.realPath(filePath))
	end Function
	
	Private Function folder_exists( folderPath )
		folder_exists = fso.FolderExists( POP_MVC.realPath(folderPath) )
	end Function
	
	Private Sub create_folder( folderPath )
		fso.CreateFolder(  POP_MVC.realPath(folderPath) )
	end Sub
End Class
%>